﻿using AppService.Dto.System_setting;
using AppService.IService.System_setting;
using Domain.Entity.System_setting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers.System_setting
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DepartController : ControllerBase
    {

        public IDepartService depart { get; set; }

        /// <summary>
        /// 查询部门
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<Ment_depart> GetDepart(string? date1, string? date2, string? value2)
        {
            return depart.GetDepart();
        }

        /// <summary>
        /// 新增部门
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        [HttpPost("register")]
        public IActionResult AddDepart([FromBody] Ment_departDto d)
        {
            bool flag = depart.AddDepart(d);
            return Ok(flag);
        }

        /// <summary>
        /// 删除部门
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete("{id}")]
        public IActionResult DelDepart(int id)
        {
            bool flag = depart.DelDepart(id);
            return Ok(flag);
        }

        /// <summary>
        /// 根据id获取部门
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("{id}")]
        public IActionResult GetById(int id)
        {
            Ment_depart ment_Depart = depart.GetDepartById(id);
            return Ok(ment_Depart);
        }

        /// <summary>
        /// 根据id获取企业信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("{id}")]
        public IActionResult GetByCompId(int id)
        {
            Info_company info_Company = depart.GetByCompId(id);
            return Ok(info_Company);
        }

        /// <summary>
        /// 修改部门信息
        /// </summary>
        /// <param name="ment_DepartDto"></param>
        /// <returns></returns>
        [HttpPut("register")]
        public IActionResult UpdDepart([FromBody] Ment_departDto ment_DepartDto)
        {
            bool flag = depart.UpdDepart(ment_DepartDto);
            return Ok(flag);
        }

    }
}
